package com.only4play.authcenter.infrastructure.convert;

/**
 * @author hinzzz www.hinzzz.cn 157957329@qq.com
 * 2024-03-05
 */
import com.only4play.authcenter.constants.ThirdPartyAuthType;

import javax.persistence.AttributeConverter;

public class ThirdPartyAuthTypeConverter implements AttributeConverter<ThirdPartyAuthType,Integer> {

  @Override
  public Integer convertToDatabaseColumn(ThirdPartyAuthType thirdPartyAuthType) {
    return thirdPartyAuthType.getCode();
  }

  @Override
  public ThirdPartyAuthType convertToEntityAttribute(Integer code) {
    return ThirdPartyAuthType.of(code).orElse(null);
  }
}
